package com.sfh.cpc.com.widget;

import android.content.Context;
import android.graphics.Color;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.Gravity;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.sfh.cpc.com.R;

/**
 * 功能描述: 魅力与财富
 *
 * @author SunFeihu 孙飞虎
 * @date 2018/8/7
 */
public class WidgetCharmWealth extends LinearLayout {
    TextView tvTitle;
    TextView tvData;

    public WidgetCharmWealth(Context context) {
        super(context);
        this.init();
    }

    public WidgetCharmWealth(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        this.init();
    }

    public WidgetCharmWealth(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        this.init();
    }

    private void init() {
        this.setGravity(Gravity.CENTER);
        this.setOrientation(HORIZONTAL);
        this.tvTitle = new TextView(this.getContext());
        this.addView(this.tvTitle);
        this.tvData = new TextView(this.getContext());
        this.addView(this.tvData);

        this.tvData.setTextSize(9.0f);
        this.tvTitle.setTextSize(9.0f);
        this.tvTitle.setPadding(10,3,5,3);
        this.tvData.setPadding(15,3,15,3);

    }


    /***
     * 设置数据 ->财样式
     */
    public void setStyleWealth(String size) {
        this.tvTitle.setText("财");
        this.tvTitle.setTextColor(Color.parseColor("#333333"));
        this.tvTitle.setBackgroundResource(R.drawable.file_wealth_left);
        this.tvData.setBackgroundResource(R.drawable.file_wealth_right);
        this.tvData.setTextColor(Color.parseColor("#febf3a"));
        this.tvData.setText(size);
    }

    /***
     * 设置数据 ->魅力样式
     */
    public void setStyleCharm(String size) {
        this.tvTitle.setText("魅");
        this.tvTitle.setTextColor(Color.WHITE);
        this.tvTitle.setBackgroundResource(R.drawable.file_charm_left);
        this.tvData.setBackgroundResource(R.drawable.file_charm_right);
        this.tvData.setTextColor(Color.parseColor("#f56684"));
        this.tvData.setText(size);
    }
}
